package org.shopen.puremvc.model.domain.testing
{
	import org.shopen.puremvc.model.domain.ISerializable;
	import org.shopen.puremvc.model.utils.Convert;

	public class Option implements ISerializable
	{
		[Bindable]
		private var _label : String = "";
		[Bindable]
		public function get label() : String
		{
			return _label;
		}
		public function set label(value : String) : void
		{
			_label = value;
		}
		
		[Bindable]
		private var _correctValue : String = "";
		[Bindable]
		public function get correctValue() : String
		{
			return _correctValue;
		}
		public function set correctValue(value : String) : void
		{
			_correctValue = value;
		}
		
		public function Option(node : XML = null)
		{
			if (node != null)
			{
				deserialize(node);
			}
		}

		public function deserialize(node:XML):void
		{
			if ("@label" in node)
			{
				label = Convert.toString(node.@label);
			}
			if ("@correctvalue" in node)
			{
				correctValue = Convert.toString(node.@correctvalue);
			}
		}
		
		public function serialize():XML
		{
			// TODO: consider implement if needed.
			return null;
		}
		
		public function checkCorrect(optionAnswer : Object) : Boolean
		{
			var result : Boolean = Convert.toString(optionAnswer) == correctValue;
			return result;
		}
		
		public function toString():String
		{
			return label;
		}
		
		public function clone() : Option
		{
			var result : Option = new Option();
			result.label = this.label;
			result.correctValue = this.correctValue;
			return result;
		}
		
	}
}